layui.define(['index', 'zmnApp', 'form'], function (exports) {
    let $ = layui.$;
    let form = layui.form;
    let layer = layui.layer;
    let zmnApp = layui.zmnApp;

    form.render(null, "zmn-form");

    form.on('submit(zmn-form-submit)', function (obj) {
        var staff = obj.field;

        $.post(zmnApp.SYS_BASE_URL +"/staff/dingtalk/synchro.action", {"staffId":staff.staffId,"dTalkId":staff.dTalkId}, function (res) {
            if (res.status === 200) {
                layer.msg(res.message, {"icon": 1});
                setTimeout(function () {
                    zmnLayUtil.closeThisIframe(parent);
                },1000)
            } else {
                layer.msg(res.message, {"icon": 2});
            }
        });
        return false;
    });

    //点击取消
    $(document).on('click', '#cancle', function () {
        zmnLayUtil.closeThisIframe(parent);
    });

    //对外暴露的接口
    exports('ding_talk_user_input', {});
});
